import Mock from 'mockjs';
import user from './user';
import product from './product';
import shoplist from './shoplist';
import order from './orderFrom';

// 设置响应延迟，单位为毫秒
Mock.setup({
  timeout: '200-600',
});

// 注册所有的模拟接口
const mocks = [...user, ...product, ...shoplist, ...order];

// 注册模拟接口的函数
export function registerMockServices() {
  if (process.env.NODE_ENV === 'development') {
    mocks.forEach((item) => {
      Mock.mock(new RegExp(item.url), item.method || 'get', item.response);
    });
    console.log('Mock services registered.');
  }
}